package com.pk6;

import java.util.*;

class ExpressionHelper {
    private static final Map<Character, Integer> OPERATE_PRIORITY;

    static {
        OPERATE_PRIORITY = new HashMap<>();
        OPERATE_PRIORITY.put('+', 1);
        OPERATE_PRIORITY.put('-', 1);
        OPERATE_PRIORITY.put('*', 9);
        OPERATE_PRIORITY.put('/', 9);
        OPERATE_PRIORITY.put('(', 0);
        OPERATE_PRIORITY.put(')', 0);
    }

    public String getExpressionSuffixFromMid(String expression) {
        Deque<Character> nums = new ArrayDeque<>();
        Deque<Character> ops = new ArrayDeque<>();
        for (int i = 0; i < expression.length(); i++) {
            char c = expression.charAt(i);
            Character curCharacter = new Character(c);
            if (Character.isDigit(c)) {
                // 如果是数字
                nums.push(curCharacter);
            } else {
                //非数字
                if (c == '(') {
                    ops.push(curCharacter);
                } else if (c == ')') {
                    Character popOp = ops.pop();
                    while (!popOp.equals('(')) {
                        nums.push(popOp);
                        if (!ops.isEmpty()) {
                            popOp = ops.pop();
                        }
                    }
                } else {
                    // + - * / 情况
                    // 如果为空则直接放入
                    if (ops.isEmpty()) {
                        ops.push(curCharacter);
                    } else {
                        // 比较优先级
                        Character peekOp = ops.peek();
                        Integer curPriority = OPERATE_PRIORITY.get(curCharacter);
                        while (peekOp != null && OPERATE_PRIORITY.get(peekOp).compareTo(curPriority) >= 0) {
                            nums.push(ops.pop());
                            if (ops.isEmpty()) {
                                peekOp = null;
                            } else {
                                peekOp = ops.peek();
                            }
                        }
                        ops.push(curCharacter);
                    }

                }
            }
        }
        while (!ops.isEmpty()) {
            Character popOp = ops.pop();
            nums.push(popOp);
        }
        StringBuilder sb = new StringBuilder();
        while (!nums.isEmpty()) {
            sb.append(nums.pollLast());
        }
        return sb.toString();
    }
}

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        ExpressionHelper expressionHelper = new ExpressionHelper();
        while (scanner.hasNextLine()) {
            String s = scanner.nextLine();
            String expressionSuffixFromMid = expressionHelper.getExpressionSuffixFromMid(s);
            System.out.println(expressionSuffixFromMid);
        }
    }
}
